#define _CRT_SECURE_NO_WARNINGS 1

https://leetcode.cn/problems/remove-all-adjacent-duplicates-in-string/

class Solution {
public:
    string removeDuplicates(string s) {

        stack<char> my_stack;
        string str;

        my_stack.push(s[0]);
        for (int i = 1; i < s.size(); i++)
        {
            char ch = s[i];

            if (my_stack.size() > 0)
            {
                if (ch == my_stack.top())
                    my_stack.pop();
                else
                    my_stack.push(ch);
            }
            else
                my_stack.push(ch);
        }

        while (my_stack.size() > 0)
        {
            str += my_stack.top();
            my_stack.pop();
        }
        reverse(str.begin(), str.end());

        return str;
    }
};